﻿using EventSys.BussinesEntities;
using EventSys.BussinesEntities.Entidades;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EventSys.Repository
{
    public class UserProfileRepository:MasterRepository,IUserProfileRepository
    {

        public void RegistrarUserProfile(UserProfile userProfile)
        {
            throw new NotImplementedException();
        }

        public UserProfile UserProfileById(int id)
        {
            throw new NotImplementedException();
        }

        public void EditarUserProfile(UserProfile userProfile)
        {
            throw new NotImplementedException();
        }

        public void EliminarUserProfile(int id)
        {
            throw new NotImplementedException();
        }

        public List<UserProfile> GetFromAllUserProfiles()
        {
            //var lista = //Context.UserProfiles.Join(Context.webpages_Membership, a => a.UserId, b => b.UserId, (a, b) => new { UserProfile = a, webpages_Membership = b });
            //            //.Select(c => new { c.UserProfile.UserId});
            //from cat in Context.UserProfiles
            //join art in Context.webpages_Membership
            //on cat.UserId equals art.UserId
            //select new UsuarioDTO
            //{ 
            //    Id = cat.UserId               
            //};

            return Context.UserProfiles.ToList();       
                    
        }

        public List<UserProfile> GetFromAllUserProfileByCriterio(string criterio)
        {
            throw new NotImplementedException();
        }


        public List<UsuarioDTO> GetFromAllUserProfilesDetalle()
        {
             //Context.UserProfiles.Join(Context.webpages_Membership, a => a.UserId, b => b.UserId, (a, b) => new { UserProfile = a, webpages_Membership = b });
                //.Select(c => new { c.UserProfile.UserId});
            var lista = from cat in Context.UserProfiles
                        join art in Context.webpages_Membership
                        on cat.UserId equals art.UserId
                        select new UsuarioDTO
                        {
                          UserId=cat.UserId,
                          Usuario=cat.UserName,
                          Nombres=cat.Nombres,
                          Apellidos=cat.Apellidos,
                          NombreCompleto=cat.Apellidos,
                          Email=cat.Correo,
                          CreationDate=art.CreateDate,
                          IsLockedOut=art.IsConfirmed,
                          LastLockoutDate=art.LastPasswordFailureDate,
                          LastLoginDate=art.PasswordChangedDate
                            
                        };

            return lista.ToList();
        }
    }
}
